//
//  XMDisturbTypeView.m
//  XunMi
//
//  Created by MacBook on 2024/4/15.
//  Copyright © 2024 TieZhu. All rights reserved.
//

#import "XMDisturbTypeView.h"

@interface XMDisturbTypeView ()

@property (weak, nonatomic) IBOutlet UIView *leftView;
@property (weak, nonatomic) IBOutlet UIView *rightView;
@property (weak, nonatomic) IBOutlet UIButton *leftStateBtn;
@property (weak, nonatomic) IBOutlet UIButton *rightStateBtn;

@end


@implementation XMDisturbTypeView

- (void)awakeFromNib {
    [super awakeFromNib];
    [self radiusWithRadius:20 corner:UIRectCornerTopLeft | UIRectCornerTopRight];
    [self.leftStateBtn setImagePosition:XMImagePositionLeft spacing:6];
    [self.rightStateBtn setImagePosition:XMImagePositionLeft spacing:6];
    self.disturb = NO;
}

- (void)setDisturb:(BOOL)disturb {
    _disturb = disturb;
    if (disturb) {
        self.rightView.layer.borderWidth = 1;
        self.rightView.layer.borderColor = kHEX(@"#FF1435").CGColor;
        self.rightView.backgroundColor = kHEX(@"#FFF4F6");
        
        self.leftView.layer.borderWidth = 1;
        self.leftView.layer.borderColor = kHEX(@"#F5F5F5").CGColor;
        self.leftView.backgroundColor = kHEX(@"#F5F5F5");
    } else {
        self.leftView.layer.borderWidth = 1;
        self.leftView.layer.borderColor = kHEX(@"#FF1435").CGColor;
        self.leftView.backgroundColor = kHEX(@"#FFF4F6");
        
        self.rightView.layer.borderWidth = 1;
        self.rightView.layer.borderColor = kHEX(@"#F5F5F5").CGColor;
        self.rightView.backgroundColor = kHEX(@"#F5F5F5");
    }
}

- (IBAction)change:(UIButton *)sender {
    self.disturb = sender.tag == 1;
    if (self.changeBlock) {
        self.changeBlock(self.disturb);
    }
}

@end
